package com.otp.model.test.template;

// Generated Apr 7, 2012 11:56:45 PM by Hibernate Tools 3.4.0.CR1

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.appfuse.model.BaseObject;


@Entity
@Table(name = "items")
public class Item extends BaseObject implements Serializable{

	private static final long serialVersionUID = 7476918761386429285L;
	private int objectId;
	private TestTemplate testTemplate;
	private TestSection testSection;
	private Integer orderInSection;
	private ResponseScoreRange responseScoreRange;
	private String description;
	private String name;
	private Double maxScore;
	private String extId;
	private Double a_discrimination;
	private Double b_difficulty;
	private Double c_geussing;

	@Column(name = "ext_id")
	public String getExtId() {
		return extId;
	}


	public void setExtId(String extId) {
		this.extId = extId;
	}


	@Column(name = "order_in_section")
	public Integer getOrderInSection() {
		return orderInSection;
	}


	public void setOrderInSection(Integer orderInSection) {
		this.orderInSection = orderInSection;
	}

	@Column(name = "description")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "name")
	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "max_score")
	public Double getMaxScore() {
		return maxScore;
	}

	public void setMaxScore(Double maxScore) {
		this.maxScore = maxScore;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "object_id", unique = true, nullable = false)
	public int getObjectId() {
		return this.objectId;
	}

	public void setObjectId(int objectId) {
		this.objectId = objectId;
	}

	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name = "fk2test_template")
	public TestTemplate getTestTemplate() {
		return this.testTemplate;
	}

	public void setTestTemplate(TestTemplate testTemplate) {
		this.testTemplate = testTemplate;
	}

	@ManyToOne(fetch = FetchType.EAGER)//TODO workaround lazyInitializationException in response-by-section comparator 
	@JoinColumn(name = "fk2test_section")
	public TestSection getTestSection() {
		return this.testSection;
	}

	public void setTestSection(TestSection testSection) {
		this.testSection = testSection;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "fk2response_score_range")
	public ResponseScoreRange getResponseScoreRange() {
		return this.responseScoreRange;
	}

	public void setResponseScoreRange(ResponseScoreRange responseScoreRange) {
		this.responseScoreRange = responseScoreRange;
	}

	@Column(name = "a_discrimination")
	public Double getA() {
		return a_discrimination;
	}

	public void setA(Double a_discrimination) {
		this.a_discrimination = a_discrimination;
	}


	@Column(name = "b_difficulty")
	public Double getB() {
		return b_difficulty;
	}


	public void setB(Double b_difficulty) {
		this.b_difficulty = b_difficulty;
	}


	@Column(name = "c_guessing")
	public Double getC() {
		return c_geussing;
	}


	public void setC(Double c_geussing) {
		this.c_geussing = c_geussing;
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (!(o instanceof Item)) {
			return false;
		}

		final Item mapItem = (Item) o;

		return objectId == mapItem.objectId;

	}

	@Override
	public int hashCode() {
		return objectId;
	}

	@Override
	public String toString() {
		return ""+objectId;
	}

}
